Q: How many stacks are required for applying evaluation of infix expression algorithm?
Solution: Two stacks are required for evaluation of infix expression – one for operands and one for operators.
Q: How many passes does the evaluation of infix expression algorithm makes through the input?
Solution: Evaluation of infix expression algorithm is linear and makes only one pass through the input.
Q: Identify the infix expression from the list of options given below.
Solution: a/b+(c-d) is an infix expression since the operators are placed in between the operands.
Q: Which of the following statement is incorrect with respect to evaluation of infix expression algorithm?
Solution: If the precedence of the operator is higher than the stack operator, then it is pushed on to the stack operator.
Q: Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 1+2*3-2
Solution: According to precedence of operators, * is evaluated first. + and – have equal priorities. Hence, 1+6-2= 5.
Q: Evaluation of infix expression is done based on precedence of operators.
Solution: During evaluation of infix expression, the operators with higher precedence are evaluated first, followed by operators with lower precedence.
Q: Of the following choices, which operator has the lowest precedence?
Solution: The operator with the lowest precedence is #, preceded by +, / and then ^.
Q: The system throws an error if parentheses are encountered in an infix expression evaluation algorithm.
Solution: The algorithm holds good for infix expression with parentheses. The system does not throw error.
Q: Evaluate the following and choose the correct answer. a/b+c*d where a=4, b=2, c=2, d=1.
Solution: * and / have higher priority. Hence, they are evaluated first. Then, + is evaluated. Hence, 2+2=4.
Q: Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 4*2+3-5/5
Solution: 4*2 and 5/5 are evaluated first and then, 8+3-1 is evaluated and the result is obtained as 10.
You Have Score    | /10 |